<template>
  <div class="range" v-if="resource != 'all'">
    <div class="range-left">
      <div class="range-header">
        <div class="unit" v-if="resource == 'org'">
          <TreeSearch
            style="width: 200px"
            ref="refTreeSelSearch"
            @changeOrgId="changeOrgId2"
            orgName="请选择组织机构"
            typeInfo="1,2,3"
            @onClear="onClear"
          ></TreeSearch>
        </div>
        <div class="unit" v-if="resource == 'org'">
          <el-input
            placeholder="请输入联网单位"
            v-model="searchForm.searchInput"
            size="small"
            clearable
            @clear="onClearInput(2)"
            style="width: 250px; margin-left: 15px"
          >
            <template slot="append">
              <el-button
                class="el-icon-search"
                @click="onClickInput(2)"
              ></el-button>
            </template>
          </el-input>
        </div>

        <!-- <div class="unit" v-if="resource == 'space'">
          <TreeSearch
            style="width: 200px"
            ref="refTreeSelSearch"
            @changeOrgId="changeOrgId"
            orgName="请选择组织机构或单位"
            typeInfo="1,2,3,4"
            @onClear="onClear"
          ></TreeSearch>
        </div>
        <div class="unit" v-if="resource == 'space'" style="margin-right: 15px">
          <el-select
            size="small"
            style="width: 200px; margin-left: 15px"
            clearable
            @change="changeBuildings"
            @keyup.enter.native="searchList"
            v-loadMore="loadBuildings"
            v-model="buildingsName"
            placeholder="请选择建筑物"
            filterable
            remote
            :remote-method="remoteBuildings"
            @clear="clearBuildings"
          >
            <el-option
              v-for="item in buildings"
              :label="item.name"
              :value="item.id"
              :key="item.id"
            >
            </el-option>
            <div
              class="div_box"
              v-loading="loading2"
              :style="loading2 ? '' : 'display: none;'"
            ></div>
          </el-select>
        </div>  -->
        <div class="unit" v-if="resource == 'space' || resource == 'device'">
          <el-input
            :placeholder="
              resource == 'space' ? '请输入安装点名称' : '请输入设备编码'
            "
            v-model="searchForm.searchInput"
            size="small"
            clearable
            @clear="onClearInput(3)"
            style="width: 220px"
          >
            <template slot="append">
              <el-button
                class="el-icon-search"
                @click="onClickInput(3)"
              ></el-button>
            </template>
          </el-input>
        </div>

        <el-popover
          placement="bottom"
          width="420"
          trigger="click"
          style="margin-left: 0px"
          popper-class="popover"
          size="small"
          v-model="showPopover"
          v-if="resource == 'space'"
        >
          <div>
            <el-form
              label-width="70px"
              style="margin: 20px 0"
              class="popover_from"
            >
              <el-form-item size="small" label="组织机构">
                <TreeSearch
                  style="width: 300px; margin-left: 15px"
                  ref="refTreeSelSearch"
                  @changeOrgId="changeOrgId"
                  @onClear="onClear"
                >
                </TreeSearch>
              </el-form-item>

              <el-form-item size="small" label="联网单位">
                <el-select
                  size="small"
                  style="width: 300px; margin-left: 15px"
                  clearable
                  v-model="selectedValue"
                  placeholder="请选择联网单位"
                  filterable
                >
                  <el-option
                    v-for="item in orgList"
                    :label="item.orgName"
                    :value="item.id"
                    :key="item.id"
                  >
                  </el-option>
                </el-select>
              </el-form-item>

              <el-form-item size="small" label="建筑物">
                <el-select
                  size="small"
                  style="width: 300px; margin-left: 15px"
                  clearable
                  @change="changeBuildings"
                  @keyup.enter.native="searchList"
                  v-loadMore="loadBuildings"
                  v-model="buildingsName"
                  placeholder="请选择建筑物"
                  filterable
                  remote
                  :remote-method="remoteBuildings"
                  @clear="clearBuildings"
                >
                  <el-option
                    v-for="item in buildings"
                    :label="item.name"
                    :value="item.id"
                    :key="item.id"
                  >
                  </el-option>
                  <div
                    class="div_box"
                    v-loading="loading2"
                    :style="loading2 ? '' : 'display: none;'"
                  ></div>
                </el-select>
              </el-form-item>

              <el-form-item size="small" label="楼层">
                <el-select
                  size="small"
                  style="width: 300px; margin-left: 15px"
                  clearable
                  @change="projectchange3"
                  v-loadMore="loadMore3"
                  v-model="floorName"
                  placeholder="请选择楼层"
                  filterable
                  remote
                  :remote-method="remoteMethod3"
                  @clear="handleClear3"
                >
                  <el-option
                    v-for="item in floor"
                    :label="item.name"
                    :value="item.id"
                    :key="item.id"
                  >
                  </el-option>
                  <div
                    class="div_box"
                    v-loading="loading3"
                    :style="loading3 ? '' : 'display: none;'"
                  ></div>
                </el-select>
              </el-form-item>
            </el-form>
            <div class="footer" style="text-align: right">
              <el-button size="small" @click="resetClick" class="cancel-button"
                >重 置</el-button
              >
              <el-button
                size="small"
                @click="searchClick1"
                class="confirm-button"
                >确 定</el-button
              >
            </div>
          </div>
          <el-button
            size="small"
            style="
              margin-left: 15px;
              background: #7367f0;
              color: #fff;
              border: none;
              font-size: 14px;
              padding: 8px 15px;
            "
            slot="reference"
            :class="hasSearch ? 'elhasSearch elhasSearch2' : 'elhasSearch2'"
          >
            高级搜索<i
              class="el-icon-search"
              style="margin-left: 5px; font-size: 12px"
            ></i
          ></el-button>
        </el-popover>
      </div>
      <div class="range-bottom">
        <el-tree
          :data="dataList"
          show-checkbox
          node-key="id"
          :props="defaultProps"
          ref="treeRef"
          :default-checked-keys="orgIdList"
          check-strictly
          :expand-on-click-node="false"
          @check="checkTree"
          v-if="resource == 'org'"
        >
        </el-tree>

        <div class="install-table" v-if="resource == 'space'">
          <el-table
            :data="tableData"
            height="280px"
            class="table"
            @selection-change="batchSelect"
            :header-cell-style="headerStyle"
            row-key="id"
            ref="refMultipleTable"
          >
            <el-table-column
              align="center"
              type="selection"
              :reserve-selection="true"
              min-width="40"
              width="45"
            >
            </el-table-column>
            <el-table-column
              align="center"
              label="序号"
              type="index"
              width="50"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="name"
              label="安装点"
              show-overflow-tooltip
            >
            </el-table-column>
          </el-table>
          <pagination
            :total="total"
            :page.sync="page"
            :limit.sync="limit"
            @pagination="getreqParkList(false)"
            class="pagination"
          />
        </div>
        <div class="install-table" v-if="resource == 'device'">
          <el-table
            :data="deviceList"
            height="280px"
            class="table"
            ref="refTableDev"
            row-key="id"
            :header-cell-style="headerStyle"
            @selection-change="batchSelectDevice"
          >
            <el-table-column
              align="center"
              type="selection"
              :reserve-selection="true"
              width="45"
            ></el-table-column>
            <el-table-column
              align="center"
              label="序号"
              type="index"
              width="50"
            >
            </el-table-column>
            <el-table-column
              align="center"
              prop="imei"
              label="设备编码"
              min-width="140"
              show-overflow-tooltip
            >
            </el-table-column>
          </el-table>
          <pagination
            :page.sync="pageDev"
            :limit.sync="limitDev"
            :total="totalDev"
            @pagination="getDataList(false)"
            class="pagination"
          >
          </pagination>
        </div>
      </div>
    </div>
    <div
      class="range-middle"
      v-if="resource == 'space' || resource == 'device'"
    >
      <div class="middle-icon">
        <i class="el-icon-arrow-right"></i>
      </div>
    </div>
    <div class="range-right" v-if="resource == 'space' || resource == 'device'">
      <div class="range-header"></div>
      <div class="install-table">
        <el-table
          :data="recordData"
          height="350"
          class="table"
          :header-cell-style="headerStyle"
          row-key="id"
          ref="refRecordData"
        >
          <el-table-column align="center" label="序号" type="index" width="50">
          </el-table-column>
          <el-table-column
            align="center"
            prop="name"
            label="安装点"
            show-overflow-tooltip
            v-if="resource == 'space'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            prop="imei"
            label="设备编号"
            show-overflow-tooltip
            v-if="resource == 'device'"
          >
          </el-table-column>
          <el-table-column
            align="center"
            label="操作"
            width="80"
            show-overflow-tooltip
          >
            <template slot-scope="scope">
              <el-tooltip
                class="item"
                effect="dark"
                content="删除"
                placement="bottom"
              >
                <i
                  @click="onDel(scope.row)"
                  class="iconfont shanchu tableBtnIcon"
                ></i>
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import tableStyleMixin from "@mixin/table-style";
import { mapState, mapMutations } from "vuex";
import {
  reqOrgList,
  reqRegionLevel,
  reqSpaceManager,
  reqProductList,
  reqProductModelPage,
  reqDeviceList,
} from "@/api/api";
import { reqByProductKey } from "@/api/rule";
import { handleTree, transTree } from "@utils/trans-tree";
import TreeSearch from "@components/TreeSearch.vue";
import Pagination from "@components/Pagination.vue";
import loadMore from "@mixin/loadMore";

export default {
  name: "",
  components: { Pagination, TreeSearch },
  props: ["resource", "rangeData", "watchIndex", "productId", "classMark"],
  data() {
    return {
      // 建筑物
      buildings: [],
      sysInstanceIndex2: 1,
      sysInstanceTotalPages2: 10,
      loading2: false,
      buildingsName: "",
      buildingsName2: "",
      targetId: "",
      searchForm: {
        searchInput: "",
        parentId: "",
      },
      tableData: [],
      page: 1,
      limit: 10,
      total: 0,
      recordData: [],
      showPopover: false,

      // 设备列表
      deviceList: [],
      pageDev: 1,
      limitDev: 10,
      totalDev: 0,
      batchDataList: [],

      orgIdList: [],
      defaultProps: {
        children: "children",
        label: "orgName",
      },
      dataList: [],
      multipleSelection: [],
      // 楼层
      floor: [],
      sysInstanceIndex3: 1,
      sysInstanceTotalPages3: 10,
      loading3: false,
      floorName: "",
      floorName2: "",
      orgList: [],
      selectedValue: "",
      hasSearch: false,
    };
  },
  computed: {
    ...mapState(["user", "spacesManage"]),
  },
  mixins: [tableStyleMixin, loadMore],
  watch: {
    watchIndex(val) {
      if (this.resource == "org") {
        this.$refs.treeRef.setCheckedKeys([]);
        this.orgIdList = this.rangeData;
        this.$nextTick(() => {
          this.$refs.treeRef.setCheckedKeys(this.orgIdList);
        });
      } else if (this.resource == "space") {
        this.$nextTick(() => {
          this.clearSelections("space");
          this.recordData = this.rangeData;
          this.recordData.forEach((item) => {
            this.$refs.refMultipleTable.toggleRowSelection(item, true);
          });
        });
      } else if (this.resource == "device") {
        this.$nextTick(() => {
          this.clearSelections("device");
          this.recordData = this.rangeData;
          this.recordData.forEach((item) => {
            this.$refs.refTableDev.toggleRowSelection(item, true);
          });
        });
      }
    },
  },
  methods: {
    // 树节点懒加载
    async loadNode(node, resolve) {
      if (node.level == 0) {
        // 如果是一级单位
        let params = {
          tenantId: this.user.tenantId,
          userId: this.user.userId,
          roleName: this.user.roleName,
          orgName: this.orgName,
          type: "1,2,3,4",
        };
        let res = await reqOrgList(params);
        if (res.code !== 20000) return this.$modal.notifyWarning(res.message);
        let { rows, total } = res.data;

        if (
          this.user.roleName == "ORG_ADMIN" ||
          this.user.roleName == "INSTERALL_USER"
        ) {
          // 组织||装维
          rows.forEach((item) => {
            if (item.hasChildren === 1) {
              item.hasChildren = false;
            } else {
              item.hasChildren = true;
            }
          });
          // 只加载选中的组织机构
          rows = rows
            .filter(
              (item) => item.id == this.spacesManage.organizationInfo.orgId
            )
            .map((item) => ({
              id: item.id,
              orgName: item.orgName,
              children: item.children,
            }));
        } else {
          // 租户级
          rows.forEach((item) => {
            if (item.hasChildren === 1) {
              item.hasChildren = false;
            } else {
              item.hasChildren = true;
            }
          });
        }
        if (rows.length > 0) {
          let data = {
            orgId: rows[0].id,
            orgName: rows[0].orgName,
            role: rows[0].role,
          };
        } else {
          // 组织机构筛选为空时
          let data = {
            orgId: "",
            orgName: "",
            role: 2,
          };
          this.$emit("toggleOrgId", data);
        }
        return resolve(rows);
      } else {
        // 否则是下级单位
        let params = {
          tenantId: this.user.tenantId,
          userId: this.user.userId,
          roleName: this.user.roleName,
          orgName: this.orgName,
          parentId: node.data.id,
          type: "1,2,3,4",
        };
        let res = await reqOrgList(params);
        if (res.code !== 20000) return this.$modal.notifyWarning(res.message);
        let rows = res.data.rows;
        rows.forEach((item) => {
          if (item.hasChildren === 1) {
            item.hasChildren = false;
          } else {
            item.hasChildren = true;
          }
        });
        return resolve(rows);
      }
    },
    getInfo() {
      this.$refs.refTreeSelSearch.getDataList();
    },
    // 组织机构筛选
    changeOrgId2(instanceId) {
      this.parentId2 = instanceId.id;
      this.getOrgList();
    },
    // 获取列表
    async getOrgList() {
      let params = {
        tenantId: this.user.tenantId,
        userId: this.user.userId,
        roleName: this.user.roleName,
        orgName: this.searchForm.searchInput,
        parentId: this.parentId2,
        type: "4",
      };
      let res = await reqOrgList(params);
      if (res.code !== 20000) return this.$modal.notifyWarning(res.message);
      // this.dataList = res.data.rows;
      this.dataList = transTree(res.data.rows); //返回全部数据
      this.flagtree = false;
      this.dataList.forEach((result) => {
        if (result.role == 1) {
          // result.orgName=result.orgName+'（管理员）'
          this.flagtree = true;
        }
      });
      this.total = res.data.total;
      this.first = true;
      if (res.data.rows.length > 0) {
        let data = {
          orgId: res.data.rows[0].id,
          orgName: res.data.rows[0].orgName,
          role: res.data.rows[0].role,
        };
        this.$emit("toggleOrgId", data);
      } else {
        // 单位筛选为空时
        let data = {
          orgId: "",
          orgName: "",
          role: 2,
        };
        this.$emit("toggleOrgId", data);
      }
    },
    async OrgList() {
      var res = await reqOrgList({
        userId: this.user.userId,
        roleName: this.user.roleName,
        tenantId: this.user.tenantId,
        orgName: "",
        parentId: "",
        type: "1,2,3,4",
      });
      if (res.code !== 20000) return this.$modal.notifyWarning(res.message);
      let { rows } = res.data;
      this.dataList = transTree(rows); //返回全部数据
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 清空搜索框
    onClearInput(type) {
      if (type == 2) {
        this.getOrgList();
        this.orgIdList = this.rangeData;
      } else if (type == 3) {
        if (this.resource == "space") {
          this.page = 1;
          this.getreqParkList(false);
        } else if (this.resource == "device") {
          this.pageDev = 1;
          this.getDataList(false);
        }
      }
    },
    onClickInput(type) {
      if (type == 2) {
        this.getOrgList();
        this.orgIdList = this.rangeData;
      } else if (type == 3) {
        if (this.resource == "space") {
          this.page = 1;
          this.getreqParkList(false);
        } else if (this.resource == "device") {
          this.pageDev = 1;
          this.getDataList(false);
        }
      }
    },
    checkTree(e) {
      const checkedNodes = this.$refs.treeRef.getCheckedNodes();
      this.onPushData(checkedNodes.map((node) => node.id));
    },

    // 搜索
    async searchClick1() {
      this.page = 1;
      this.limit = 10;
      this.showPopover = false;
      this.getreqParkList(false);
    },
    // 高级搜索重置
    async resetClick() {
      this.selectedValue = "";
      this.orgList = [];
      this.targetId = "";
      if (this.$refs.refTreeSelSearch) {
        this.$refs.refTreeSelSearch.onclose();
      }
      await this.handleClear();
      this.page = 1;
      this.getreqParkList();
    },
    // 清空
    async handleClear() {
      this.orgName = "";
      this.orgList = [];
      await this.getOrgList();
      await this.onClear();
    },

    // 设备列表
    async getDataList(clear = true) {
      if (this.timeArr == null) {
        this.timeArr = "";
      }
      let { searchInput } = this.searchForm;
      const res = await reqDeviceList(this.pageDev, this.limitDev, {
        userId: this.user.userId,
        roleName: this.user.roleName,
        tenantId: this.user.tenantId,
        imei: searchInput,
        // orgId: this.targetId,
        orgId: "",
        productId: this.productId || "",
        classMark: this.classMark || "",
      });
      if (res.code !== 20000) return this.$modal.notifyWarning(res.message);
      this.deviceList = res.data.rows;
      this.totalDev = res.data.total;
      this.dataReplaceDev();
    },
    // 数据替换
    dataReplaceDev() {
      this.recordData.forEach((item) => {
        this.deviceList.forEach((dataItem) => {
          if (dataItem.id === item.id) {
            this.$refs.refTableDev.toggleRowSelection(item, false);
            this.$refs.refTableDev.toggleRowSelection(dataItem, true);
          }
        });
      });
    },
    batchSelectDevice(arr) {
      this.batchDataList = [];
      arr.forEach((c) => {
        this.batchDataList.push(c.id);
      });

      // 用于记录的表格数据
      this.recordData = arr;
      this.onPushData(arr);
    },

    //场所
    // 组织机构筛选
    async changeOrgId(instanceId) {
      if (this.targetId == instanceId.id) return;
      this.targetId = instanceId.id;
      await this.getInitDataList();
      this.getOrgList2();
    },
    // 请求单位列表
    async getOrgList2() {
      let { tenantId, userId, roleName } = this.user;
      const res = await reqOrgList({
        tenantId,
        userId,
        roleName,
        orgName: this.orgName,
        parentId: this.targetId,
        type: "4",
      });
      if (res.code !== 20000) return this.$modal.notifyWarning(res.message);
      this.orgList = res.data.rows;
    },
    onClear() {
      this.targetId = this.spacesManage.organizationInfo.orgId || "";
      this.getInitDataList();
    },
    async getInitDataList() {
      await this.clearBuildings();
      // this.clearSelections("space");
    },
    // 清空复选框
    clearSelections(type) {
      if (type == "space") {
        this.$refs.refMultipleTable.clearSelection();
        // this.$nextTick(() => {});
      } else if (type == "device") {
        this.$refs.refTableDev.clearSelection();
        // this.$nextTick(() => {});
      }
    },
    // 获取建筑物列表
    // 建筑物列表
    async getBuildings() {
      let res = await reqSpaceManager(this.sysInstanceIndex2, 10, {
        userId: this.user.userId,
        roleName: this.user.roleName,
        metaCode: 1,
        orgId: this.selectedValue == "" ? this.targetId : this.selectedValue, //机构||单位
        isStatistics: 0,
        name: this.buildingsName2,
      });
      if (res.code !== 20000) return this.$modal.notifyWarning(res.message);
      this.sysInstanceTotalPages2 = res.data.total;
      this.buildings = [...this.buildings, ...res.data.rows];
    },
    // 远程搜索
    async remoteBuildings(query) {
      this.buildingsName = query; //保留输入的值
      this.buildingsName2 = query; //保留输入的值
      this.sysInstanceIndex2 = 1;
      this.sysInstanceTotalPages2 = 10;
      this.buildings = [];
      this.getBuildings();
    },
    // 选择建筑物
    changeBuildings(e) {
      this.searchForm.parentId = e;
      this.sysInstanceIndex3 = 1;
      this.sysInstanceTotalPages3 = 10;
      this.floor = [];
      this.SpaceManager();
      // this.getreqParkList(false);
    },
    // 建筑物操作
    async loadBuildings() {
      if (this.sysInstanceIndex2 >= Math.ceil(this.sysInstanceTotalPages2 / 10))
        return;
      this.sysInstanceIndex2++;
      this.loading2 = true;
      // 获取列表数据的方法
      // this.buildings = [];
      await this.getBuildings();
      this.loading2 = false;
    },
    // 清空建筑物
    clearBuildings() {
      this.searchForm.parentId = "";
      this.buildingsName = "";
      this.buildingsName2 = "";
      this.sysInstanceIndex2 = 1;
      this.sysInstanceTotalPages2 = 10;
      this.buildings = [];
      this.sysInstanceIndex3 = 1;
      this.floorName = "";
      this.floorName2 = "";
      this.floor = [];
      this.getBuildings();
    },

    // 楼层

    // 清空
    handleClear3() {
      this.floorName = "";
      this.floorName2 = "";
      this.sysInstanceIndex3 = 1;
      this.sysInstanceTotalPages3 = 10;
      this.floor = [];
      this.searchForm.parentId = this.buildingsName;
      if (this.searchForm.parentId != "") {
        this.SpaceManager();
      }
    },
    // 远程搜索
    async remoteMethod3(query) {
      this.floorName = query;
      this.floorName2 = query;
      this.sysInstanceIndex3 = 1;
      this.sysInstanceTotalPages3 = 10;
      this.floor = [];
      this.SpaceManager();
    },
    projectchange3(e) {
      this.searchForm.parentId = e;
      // this.searchClick1();
    },
    // 楼层操作
    async loadMore3() {
      if (this.sysInstanceIndex3 >= Math.ceil(this.sysInstanceTotalPages3 / 10))
        return;
      this.sysInstanceIndex3++;
      this.loading3 = true;
      // 获取列表数据的方法
      await this.SpaceManager();
      this.loading3 = false;
    },
    // 楼层列表
    async SpaceManager() {
      let res = await reqSpaceManager(this.sysInstanceIndex3, 10, {
        userId: this.user.userId,
        roleName: this.user.roleName,
        metaCode: 2,
        orgId: this.selectedValue == "" ? this.targetId : this.selectedValue, //机构||单位
        parentId: this.searchForm.parentId,
        isStatistics: 0,
        name: this.floorName2,
      });
      if (res.code !== 20000) return this.$modal.notifyWarning(res.message);
      this.sysInstanceTotalPages3 = res.data.total;
      this.floor = [...this.floor, ...res.data.rows];
    },

    // 空间列表
    async getreqParkList(clear = true) {
      let res = await reqSpaceManager(this.page, this.limit, {
        userId: this.user.userId,
        roleName: this.user.roleName,
        name: this.searchForm.searchInput,
        orgId: this.selectedValue == "" ? this.targetId : this.selectedValue, //机构||单位
        isDefence: this.searchForm.isDefence,
        // parentId: Flag ? id : this.parentId, // 如果只选了建筑物就是建筑物的id,选了楼层就是传楼层的id
        parentId: this.searchForm.parentId, // 如果只选了建筑物就是建筑物的id,选了楼层就是传楼层的id
        metaCode: 3,
        isStatistics: 1,
      });
      if (res.code !== 20000) return this.$modal.notifyWarning(res.message);
      this.hasSearch =
        this.selectedValue || this.targetId || this.searchForm.parentId
          ? true
          : false;
      this.tableData = res.data.rows;
      this.total = res.data.total;
      this.dataReplace();
    },
    // 数据替换
    dataReplace() {
      this.recordData.forEach((item) => {
        this.tableData.forEach((dataItem) => {
          if (dataItem.id === item.id) {
            this.$refs.refMultipleTable.toggleRowSelection(item, false);
            this.$refs.refMultipleTable.toggleRowSelection(dataItem, true);
          }
        });
      });
    },
    // 选择复选框批量
    batchSelect(arr) {
      this.batchDate = [];
      arr.forEach((c) => {
        this.batchDate.push(c.id);
      });
      // 用于记录的表格数据
      this.recordData = arr;
      this.onPushData(arr);
    },
    // 删除记录
    onDel(row) {
      this.findIndex = this.recordData.findIndex((item) => item.id === row.id);
      this.recordData.splice(this.findIndex, 1);
      if (this.resource == "space") {
        this.$nextTick(() => {
          this.$refs.refMultipleTable.toggleRowSelection(row, false);
        });
      } else if (this.resource == "device") {
        this.$nextTick(() => {
          this.$refs.refTableDev.toggleRowSelection(row, false);
        });
      }
    },

    // 传数据到父组件
    onPushData(data) {
      this.$emit("onPushData", data, "execute");
      // if (this.rangeType == "trigger") {
      //   this.$emit("onPushData", data);
      // } else {
      //   this.$emit("onPushData", data);
      // }
    },
  },
};
</script>

<style scoped lang="less">
@import url("./ruleOperate.less");
@import url("~@views/style/tablePage.less");
</style>
